<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">零钱</block>
		</cu-custom>
		<view class="bg02" :style="'background-image:url(' + imgurl + 'bg05.png)'">
			<view style="padding: 50rpx 0 0 50rpx;">
				<view class="flex">
					<text class="fs22 fw600 text-white mr15">可用零钱(元)</text>
					<view @tap="openeye">
						<image v-if="eye" :src="imgurl + 'eyeopen.png'" class="img30" style="position: relative;top: 6rpx;"></image>
						<image v-else :src="imgurl + 'eyeclose.png'" class="img30" style="position: relative;top: 6rpx;"></image>
					</view>
				</view>
				<view class="fs60 text-white ff" v-if="eye" v-text="UserBalance.LiveMoney">0</view>
				<view class="fs60 text-white ff" v-else>****</view>
				<view class="flex mt30" style="padding-bottom: 50rpx;">
					<view style="margin-right: 100rpx;">
						<view class="fs22 fw600 text-white">提现冻结(元)</view>
						<view class="fs40 ff text-white" v-text="UserBalance.LinMoney">0</view>
					</view>
					<view>
						<view class="fs22 fw600 text-white">待入账收益(元)</view>
						<view class="fs40 ff text-white" v-text="UserBalance.WaitProfit">0</view>
					</view>
				</view>
			</view>
			<navigator url="/pages/my/lingqianDetail" class="lingqian">
				<image :src="imgurl + '/lingqian.png'" class="img20 mr10"></image>
				<text class="fs22 fw600 text-white">零钱明细</text>
			</navigator>
		</view>

		<navigator url="/pages/my/tixian" class="qui-cells qui-card" v-if="openWithdrawals">
			<view class="qui-cell">
				<view class="cell-hd"><image :src="imgurl + '/icon_lq01.png'" class="img32"></image></view>
				<view class="cell-bd fs26 fw600">提现</view>
				<view class="arrow-r"></view>
			</view>
		</navigator>
		<navigator url="/pages/my/chongzhi" class="qui-cells qui-card" v-if="openRecharge" >
			<view class="qui-cell">
				<view class="cell-hd"><image :src="imgurl + '/icon_lq02.png'" class="img32"></image></view>
				<view class="cell-bd fs26 fw600">充值</view>
				<view class="arrow-r"></view>
			</view>
		</navigator>
		<navigator url="/pages/my/donate" class="qui-cells qui-card" v-if="openDonate">
			<view class="qui-cell">
				<view class="cell-hd"><image :src="imgurl + '/icon_lq03.png'" class="img32"></image></view>
				<view class="cell-bd fs26 fw600">转赠</view>
				<view class="arrow-r"></view>
			</view>
		</navigator>
	</view>
</template>

<script>
import base from 'utils/base.js';

export default {
	data() {
		return {
			imgurl: this.$imgurl,
			eye: true,
			UserBalance: { LiveMoney: 0, LinMoney: 0, WaitProfit: 0 },
			openWithdrawals: false,
			openRecharge:false,
			openDonate:false
		};
	},
	mounted() {
		this.GetWithdrawalsSet();
		this.GetRechargeSet();
		this.GetDonateSet();
	},
	onShow: function() {
		this.GetUserBalance();
	},
	methods: {
		showbox() {
			this.openbox = !this.openbox;
		},
		openeye() {
			this.eye = !this.eye;
		},

		GetUserBalance: function() {
			let currentPage = this;
			let globalData = getApp().globalData;
			let params = {
				hideLoading: true,
				type: 'GET',
				url: '/api/UserInfo/GetUserBalance',
				data: { typeId: 6 },
				sCallback: function(response) {
					if (response.IsSuccess) {
						let userBalance = response.Data;
						currentPage.UserBalance = userBalance;
					} else {
						uni.showToast({
							title: response.Msg
						});
					}
				}
			};
			base.request(params);
		},
		GetWithdrawalsSet: function() {
			let currentPage = this;
			let globalData = getApp().globalData;
			let params = {
				type: 'GET',
				url: '/api/Withdrawals/GetWithdrawalsSet',
				data: {},
				sCallback: function(response) {
					if (response.IsSuccess) {
						let WithdrawalsSet = response.Data;
						if (WithdrawalsSet != null && WithdrawalsSet.IsOpen == '1') currentPage.openWithdrawals = true;
					} else {
						uni.showToast({
							title: response.Msg
						});
					}
				}
			};
			base.request(params);
		},
		GetRechargeSet: function() {
			let currentPage = this;
			
			let params = {
				type: 'GET',
				url: '/api/Recharge/GetRechargeSet',
				data: {type:6},
				sCallback: function(response) {
					if (response.IsSuccess) {
					let	RechargeSet=response.Data;
						if (RechargeSet != null && RechargeSet.Status>0) currentPage.openRecharge = true;
						
		
					} else {
						tools.showToast(response.msg);
					}
				}
			};
			base.request(params);
		},
		GetDonateSet: function() {
			let currentPage = this;
			let globalData = getApp().globalData;
			let params = {
				type: 'GET',
				url: '/api/Donate/GetDonateSet',
				data: {type:6},
				sCallback: function(response) {
					if (response.IsSuccess) {
						let donateSet = response.Data;
						if (donateSet != null && donateSet.State == '1') currentPage.openDonate = true;
					} else {
						tools.showToast(response.Msg);
					}
				}
			};
			base.request(params);
		},
	}
};
</script>

<style lang="scss">
.bg02 {
	background-size: 100%;
	background-repeat: no-repeat;
	margin: 30rpx;
	position: relative;
}

.fs60 {
	font-size: 60rpx;
}

.fs40 {
	font-size: 40rpx;
}

.img20 {
	width: 20rpx;
	height: 20rpx;
}
.img32 {
	width: 32rpx;
	height: 32rpx;
	position: relative;
	top: 6rpx;
}

.lingqian {
	height: 44rpx;
	line-height: 44rpx;
	padding: 0 20rpx;
	background-color: rgba(255, 255, 255, 0.15);
	border-radius: 22rpx 0rpx 0rpx 22rpx;
	position: absolute;
	top: 63rpx;
	right: 0;
}

.img30 {
	width: 30rpx;
	height: 30rpx;
	position: relative;
	top: 5rpx;
	margin-right: 10rpx;
}
</style>
